<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请事项') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('事项名称') }}</td>
        <td>
          {{ form.itemName }}
        </td>
        <td class="tit">{{ $t('发生时间') }}</td>
        <td>{{ parseTime(form.happenTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('事项类别') }}</td>
        <td>
          <el-select v-model="form.itemType">
            <el-option
              v-for="dict in itemTypeOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </td>
        <td class="tit">{{ $t('是否处理') }}</td>
        <td>
          <el-radio-group v-model="form.handle" @change="handleChange">
            <el-radio
              v-for="dict in handleOptions"
              :key="dict.dictValue"
              :label="dict.dictValue"
            >{{ $t(dict.dictLabel) }}</el-radio>
          </el-radio-group>
        </td>
      </tr>
      <tr v-if="isShow">
        <td class="tit">{{ $t('处理日期') }}</td>
        <td>
          {{ parseTime(form.handleTime) }}
        </td>
        <td class="tit">{{ $t('处理方式') }}</td>
        <td>
          {{ form.handleMode }}
        </td>
      </tr>
      <tr v-if="isShow">
        <td class="tit">{{ $t('处理描述') }}</td>
        <td colspan="3">
          {{ form.handleDesc }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('事项描述') }}</td>
        <td colspan="3">
          {{ form.itemDesc }}
        </td>
      </tr>

    </table>

    <FileView :list.sync="form.fileList" data-type="deal_matters" :business-id="autoBusinessId($route.query.id, form)" :btn-show="!otherBtnHide" />

  </div>
</template>

<script>
    import { getDealMatters } from '@/api/deal/matters/dealMatters'

    export default {
        data() {
            return {
                // 事项类别 字典deal_matters_category字典
                itemTypeOptions: [], // 是否处理 字典sys_yes_no字典
                handleOptions: [], // 表单参数
                form: {
                  fileList: []
                },
                isShow: false,
                // 是否隐藏保存按钮
                btnHide: false,
                // 是否隐藏其它按钮
                otherBtnHide: false,

                // 遮罩层
                loading: false,
                // 操作按钮默认不展示
                buttonShow: true
            }
        },
        created() {
            this.getDicts('deal_matters_category').then(response => {
                this.itemTypeOptions = response.data
            })
            this.getDicts('sys_yes_no').then(response => {
                this.handleOptions = response.data
            })
            this.$bus.$emit('async_done')
        },
        methods: {
          // 初始化数据
          init(data) {
            this.loading = true
              if (data != null && data.id !== undefined && data.id !== '' && data.id !== null) {
                  getDealMatters(data.id).then(response => {
                      this.form = response.data
                      this.handleChange(this.form.handle)
                    this.loading = false
                  })
              }
          },

          handleChange(value) {
            // eslint-disable-next-line no-empty
            if (value === 'Y') {
              this.isShow = true
            } else {
              this.isShow = false
              this.form.handleTime = undefined
              this.form.handleMode = undefined
              this.form.handleDesc = undefined
            }
          }

        }

    }
</script>
